home *** CD-ROM | disk | FTP | other *** search
/ ASME's Mechanical Engine…ing Toolkit 1997 December / ASME's Mechanical Engineering Toolkit 1997 December.iso / cad_elec / gerbtool.exe / DATA.1 / UTILS.MAC < prev    next >
Text File  |  1995-10-23  |  7KB  |  413 lines

  1. MACRO lyrvis
  2.  
  3. # This macro prompts the user for a list of layers to change the
  4. # visibility of. Negative layer values indicate a layer should
  5. # be turned OFF, positive values indicate ON.
  6.  
  7.     GetString "Enter layer list", $lyrlist
  8.  
  9.     StrTok $slyr, ",", $lyrlist
  10.  
  11.     REPEAT $$STATUS > 0
  12.  
  13.         StrRead $slyr, "%n", $lyr        # convert string into a numeric value
  14.  
  15.         IF $lyr < 0
  16.             Calc $mode = 0                    # OFF
  17.             Calc $lyr = 0 - $lyr            # invert
  18.         ELSE
  19.             Calc $mode = 1                    # ON
  20.         END
  21.  
  22.         CallMacro "IsValidLayer", $lyr
  23.  
  24.         IF $$STATUS
  25.             LAYERN $lyr
  26.                 Visibility $mode
  27.             END
  28.         ELSE
  29.             StrWrite $msg, "invalid layer: %.0n", $lyr
  30.             MessageBox "Problem!", $msg, 0
  31.         END
  32.  
  33.         StrTok $slyr, ",", 0
  34.  
  35.     END
  36.  
  37.     Redraw
  38.  
  39. END
  40.  
  41.  
  42. MACRO FixBlankDcodes
  43.  
  44. #debug 1
  45.  
  46.     MessageBox "FixBlankDcodes", \
  47.            "This macro finds all blank dcodes and\nprompts you to correct them.", \
  48.            1
  49.  
  50.     StrCpy $tempfile, "_temp_.tmp"
  51.     StrSet $apfile, ""
  52.     StrSet $shape, ""
  53.  
  54.     Set $dcode = 0
  55.     Set $xs = 0
  56.     Set $ys = 0
  57.     Set $maxlyr = 0
  58.     Set $redraw = $$FALSE
  59.  
  60.     IF $$PLATFORM == 1        # MSDOS
  61.         Set $listok = $$TRUE
  62.     ELSE
  63.         IF $$PLATFORM == 3        # WINDOWS
  64.             Set $listok = $$FALSE
  65.             StrArray $aplists(20)    # 20 is arbitrary, increase as needed
  66.         END
  67.     END
  68.  
  69.  
  70.     CallMacro "MaxLoadedLayer", $maxlyr
  71.  
  72.     APREPORT
  73.         RepFile    $tempfile
  74.         Layer    0
  75.         SortBy    "List"
  76.         GO
  77.     END
  78.  
  79.     FileOpen $fd, $tempfile, "r"
  80.  
  81.     IF $$STATUS
  82.  
  83.         FileRead $fd, "", $line
  84.  
  85.         REPEAT $$STATUS
  86.  
  87.             IF $listok == $$FALSE
  88.  
  89.                 StrSub $buf, 1, 20, $line
  90.                 StrCmp $buf, "Aperture List Legend"
  91.  
  92.                 IF $$STATUS == 0
  93.  
  94.                     FileRead $fd, "", $line
  95.  
  96.                     REPEAT $$STATUS
  97.  
  98.                         Calc $apidx = -1
  99.                         StrRead $line, "%n - %s", $apidx, $apfile
  100.  
  101.                         IF $apidx > 0
  102.                             IF $apidx > 20
  103.                                 STOP "Too many aperture lists..."
  104.                             END
  105.                             StrCpy $aplists($apidx), $apfile
  106.                             Calc $listok = $apidx
  107.                             FileRead $fd, "", $line
  108.                         ELSE
  109.                             Calc $$STATUS = 0
  110.                         END
  111.  
  112.                     END
  113.  
  114.                 END
  115.  
  116.                 ViewAll
  117.  
  118.             END
  119.  
  120.             StrLoc $line, "?"
  121.  
  122.             IF $$STATUS > 0
  123.  
  124.                 IF $$PLATFORM == 1        # MSDOS
  125.                     StrRead $line, "? %s D%n %s %n x %n", $apfile, $dcode, $shape, $xs, $ys
  126.                 ELSE
  127.                     IF $$PLATFORM == 3        # WINDOWS
  128.                         StrRead $line, "%n D%n ?%s %n x %n", $apidx, $dcode, $shape, $xs, $ys
  129.                         StrCpy $apfile, $aplists($apidx)
  130.                     END
  131.                 END
  132.  
  133.                 CallMacro "_GetLayerNo", $maxlyr, $apfile
  134.                 Calc $lyr = $$STATUS
  135.  
  136. #                Redraw
  137.  
  138.                 HILIDCODE
  139.                     FLASHES $$TRUE
  140.                     DRAWS $$TRUE
  141.                     ARCS $$TRUE
  142.                     DCODE $dcode
  143.                     LAYER $lyr
  144.                     GO
  145.                 END
  146.  
  147.                 StrWrite $line, "%.0n items found\nD-Code: %.0n\nShape: %s\nSize: %.4n, %.4n\n\nCorrect this D-Code?", $$STATUS, $dcode, $shape, $xs, $ys
  148.                 MessageBox "Confirm", $line, 2
  149.  
  150.                 IF $$STATUS
  151.  
  152.                     GetApInfo $lyr, $dcode, $shp, $xs, $ys, $type, $tool, $toolsize, $legend
  153.  
  154.                     CallMacro "_ApNoToShape", $shp, $shape
  155.                     GetString "Enter new shape", $shape
  156.                     CallMacro "_ApShapeToNo", $shape, $shp
  157.  
  158.                     StrWrite $line, "%.4n,%.4n", $xs, $ys
  159.                     GetString "Enter new size", $line
  160.  
  161.                     Calc $ys = 0.0
  162.                     StrRead $line, "%n,%n", $xs, $ys
  163.  
  164.                     IF $ys == 0.0
  165.                         Calc $ys = $xs
  166.                     END
  167.  
  168.                     PutApInfo $lyr, $dcode, $shp, $xs, $ys, $type, $tool, $toolsize, $legend
  169.  
  170.                     Calc $redraw = $$TRUE
  171.  
  172.                 END
  173.    
  174.                 HILIDCODE
  175.                     FLASHES $$FALSE    # this should turn off current highlights
  176.                     DRAWS $$FALSE
  177.                     ARCS $$FALSE
  178.                     DCODE 10
  179.                     LAYER 1
  180.                     GO
  181.                 END
  182.  
  183.                 Redraw
  184.  
  185.             END
  186.  
  187.             FileRead $fd, "", $line
  188.  
  189.         END
  190.  
  191.     END
  192.  
  193.     IF $redraw 
  194.         Redraw
  195.     END
  196.  
  197. END
  198.  
  199.  
  200. MACRO _GetLayerNo
  201.  
  202.     Set $lyr = 1
  203.  
  204.     REPEAT $lyr <= $1
  205.  
  206.         ActiveLayer $lyr
  207.  
  208.         IF $$STATUS
  209.  
  210.             GetLayer $lyr, $fn, $ln, $ap, $vis, $fc, $dc, $type, \
  211.                  $pol, $key, $ftype, $lx, $ly, $ux, $uy, $netid
  212.  
  213.             StrCmp $ap, $2
  214.  
  215.             IF $$STATUS == 0
  216.                 Calc $$STATUS = $lyr
  217.                 Calc $lyr = $1
  218.             END
  219.  
  220.         END
  221.  
  222.         Calc $lyr = $lyr + 1
  223.  
  224.     END
  225.  
  226. END
  227.  
  228.  
  229. MACRO IsValidLayer
  230.  
  231.     IF $$CALLDEPTH == 0
  232.         STOP "This macro must be called from another macro..."
  233.     END
  234.  
  235.     Calc $$STATUS = $$FALSE
  236.  
  237.     IF $1 > 0
  238.         IF $1 <= $$MAXLAYERS
  239.             Calc $$STATUS = $$TRUE
  240.         END
  241.     END
  242.  
  243. END
  244.  
  245.  
  246. MACRO IsLayerVis
  247.     IF $$CALLDEPTH == 0
  248.         STOP "This macro must be called from another macro..."
  249.     END
  250.  
  251.     GetLayer    $1, $fn, $ln, $ap, $vis, $fc, $dc, $type, $pol, $key, $ftype,\
  252.                 $lx, $ly, $ux, $uy, $netid
  253.  
  254.     Calc $$STATUS = $vis
  255. END
  256.  
  257.  
  258. MACRO MaxLoadedLayer
  259.  
  260.     IF $$CALLDEPTH == 0
  261.         STOP "This macro must be called from another macro..."
  262.     END
  263.  
  264.     Set $1 = $$MAXLAYERS + 1
  265.  
  266.     REPEAT $$STATUS == $$FALSE
  267.  
  268.         Calc $1 = $1 - 1
  269.  
  270.         ActiveLayer $1
  271.  
  272.     END
  273.  
  274. END
  275.  
  276.  
  277. MACRO MaxLoadedAp
  278.  
  279.     IF $$CALLDEPTH == 0
  280.         STOP "This macro must be called from another macro..."
  281.     END
  282.  
  283. #    Set $2 = 4000
  284.     Set $2 = 999        # lowered to speed up...
  285.  
  286.     REPEAT $$STATUS == $$FALSE
  287.  
  288.         Calc $2 = $2 - 1
  289.  
  290.         GetApInfo $1, $2, $shp, $xs, $ys, $type, $tool, $toolsize, $legend
  291.  
  292.     END
  293.  
  294. END
  295.  
  296.  
  297. MACRO _ApNoToShape
  298.     IF $1 == $$ROUND
  299.         StrCpy $2, "Round"
  300.     ELSE
  301.         IF $1 == $$SQUARE
  302.             StrCpy $2, "Square"
  303.         ELSE
  304.             IF $1 == $$RECTANGLE
  305.                 StrCpy $2, "Rectangle"
  306.             ELSE
  307.                 IF $1 == $$OBLONG
  308.                     StrCpy $2, "Oblong"
  309.                 ELSE
  310.                     IF $1 == $$OCTAGON
  311.                         StrCpy $2, "Octagon"
  312.                     ELSE
  313.                         IF $1 == $$THERMAL
  314.                             StrCpy $2, "Thermal"
  315.                         ELSE
  316.                             IF $1 == $$THERMAL45
  317.                                 StrCpy $2, "Thermal45"
  318.                             ELSE
  319.                                 IF $1 == $$TARGET
  320.                                     StrCpy $2, "Target"
  321.                                 ELSE
  322.                                     IF $1 == $$DONUT
  323.                                         StrCpy $2, "Donut"
  324.                                     ELSE
  325.                                         IF $1 == $$DIAMOND
  326.                                             StrCpy $2, "Diamond"
  327.                                         ELSE
  328.                                             IF $1 == $$CUSTOM
  329.                                                 StrCpy $2, "Custom"
  330.                                             ELSE
  331.                                                 IF $1 == $$COMPLEX
  332.                                                     StrCpy $2, "Complex"
  333.                                                 END
  334.                                             END
  335.                                         END
  336.                                     END
  337.                                 END
  338.                             END
  339.                         END
  340.                     END
  341.                 END
  342.             END
  343.         END
  344.     END
  345. END
  346.  
  347.  
  348. MACRO _ApShapeToNo
  349.     StrSub $shp, 1, 2, $1
  350.     StrCmp $shp, "Ro"
  351.     IF $$STATUS == 0
  352.         Calc $2 = $$ROUND
  353.     ELSE
  354.          StrCmp $shp, "Sq"
  355.         IF $$STATUS == 0
  356.             Calc $2 = $$SQUARE
  357.         ELSE
  358.             StrCmp $shp, "Re"
  359.             IF $$STATUS == 0
  360.                 Calc $2 = $$RECTANGLE
  361.             ELSE
  362.                 StrCmp $shp, "Ob"
  363.                 IF $$STATUS == 0
  364.                     Calc $2 = $$OBLONG
  365.                 ELSE
  366.                     StrCmp $shp, "Oc"
  367.                     IF $$STATUS == 0
  368.                         Calc $2 = $$OCTAGON
  369.                     ELSE
  370.                         StrCmp $shp, "TH"
  371.                         IF $$STATUS == 0
  372.                             StrLoc $1, "45"
  373.                             IF $$STATUS > 0
  374.                                 Calc $2 = $$THERMAL45
  375.                             ELSE
  376.                                 Calc $2 = $$THERMAL
  377.                             END
  378.                         ELSE
  379.                             StrCmp $shp, "Ta"
  380.                             IF $$STATUS == 0
  381.                                 Calc $2 = $$TARGET
  382.                             ELSE
  383.                                 StrCmp $shp, "Do"
  384.                                 IF $$STATUS == 0
  385.                                     Calc $2 = $$DONUT
  386.                                 ELSE
  387.                                     StrCmp $shp, "Di"
  388.                                     IF $$STATUS == 0
  389.                                         Calc $2 = $$DIAMOND
  390.                                     ELSE
  391.                                         StrCmp $shp, "Cu"
  392.                                         IF $$STATUS == 0
  393.                                             Calc $2 = $$CUSTOM
  394.                                         ELSE
  395.                                             StrCmp $shp, "Co"
  396.                                             IF $$STATUS == 0
  397.                                                 Calc $2 = $$COMPLEX
  398.                                             ELSE
  399.                                                 Calc $2 = $$ROUND
  400.                                             END
  401.                                         END
  402.                                     END
  403.                                 END
  404.                             END
  405.                         END
  406.                     END
  407.                 END
  408.             END
  409.         END
  410.     END
  411. END
  412.  
  413.